import { getCategoryAPI } from '@/api/home'

export default {
  namespaced: true,
  state: {
    categoryList: []
  },
  mutations: {
    setCategoryList (state, list) {
      state.categoryList = list
    }
  },
  actions: {
    async fetchCategoryList ({ commit }) {
      const res = await getCategoryAPI()
      commit('setCategoryList', res.result)
    }
  }
}

// 完成了vuex管理数据的所有代码 -> 找一个合适的地方出发action函数
